package com.tledu.mr;
// 将纯英文放到一个partition里，其它放到另一个partition里

import org.apache.hadoop.mapreduce.Partitioner;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class MyPartition<Text,IntWritable > extends Partitioner<Text, IntWritable> {
    @Override
    public int getPartition(Text text, IntWritable intWritable, int i) {
        // 根据key进行判断
        Pattern pattern = Pattern.compile("[a-zA-Z]*");
        Matcher matcher  =pattern.matcher(text.toString());
        if (matcher.matches()) {
            return 0;
        }else {
            return 1;
        }
    }
}
